package com.metaaps.eoclipse;

import gov.nasa.worldwind.Model;
import gov.nasa.worldwind.WorldWind;
import gov.nasa.worldwind.avlist.AVKey;
import gov.nasa.worldwind.awt.WorldWindowGLCanvas;

import java.awt.BorderLayout;
import java.awt.Frame;

import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;

public class WorldWindView extends ViewPart {

	public static final String ID = "EOclipse.worldwindview";
	WorldWindowGLCanvas world = new WorldWindowGLCanvas();
	private Frame worldFrame;


	/**
	 * This is a callback that will allow us to create the viewer and initialize
	 * it.
	 */
	public void createPartControl(Composite parent) {
		// GUI: an SWT composite on top
		Composite top = new Composite(parent, SWT.EMBEDDED);
		top.setLayoutData(new GridData(GridData.FILL_BOTH));
		// Swing Frame and Panel
		worldFrame = SWT_AWT.new_Frame(top);
		worldFrame.setLayout(new java.awt.BorderLayout());

		// Add the WWJ 3D OpenGL Canvas to the Swing Frame
		Model m = (Model) WorldWind.createConfigurationComponent(AVKey.MODEL_CLASS_NAME);
		world.setModel(m);
		worldFrame.add(world, BorderLayout.CENTER);

		parent.setLayoutData(new GridData(GridData.FILL_BOTH));

	}

	/**
	 * Passing the focus request to the viewer's control.
	 */
	public void setFocus() {
		
	}
	

}
